﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using SIPO.Library.DomainObject.Administration;
using SIPO.Library.DataAccess.Administration;
using SIPO.Library.DomainObject.Transaction;
using SIPO.Library.DataAccess.Transaction;
using System.Configuration;
using SIPO.Library.DataAccess.Administration.Catalog;
using SIPO.Library.DomainObject.Administration.Catalog;
using SIPO.Library.DataAccess.Report;
using System.Data;

namespace SIPO.Web.Reports.Transaction
{
    public partial class rptRecBilling : BasePage 
    {
        protected override void OnLoad(EventArgs e)
        {
            if(!IsPostBack)
            {
                recTransactionTypeRepo recTransactionTypeDal = new recTransactionTypeRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);
                rptRecBillingRepo rptRecBillingDal = new rptRecBillingRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);

                //populate dropdownlist transactionType
                List<recTransactionType> transTypes = recTransactionTypeDal.GetList();

                ddlJenisTagihan.Items.Clear();
                if (transTypes.Count > 0)
                {
                    transTypes.ForEach(delegate(recTransactionType transType)
                    {
                        ddlJenisTagihan.Items.Add(new ListItem(transType.TransTypeCode + "-" + transType.TransTypeName, transType.TransTypeID.ToString()));
                    });
                }
                ddlJenisTagihan.Items.Insert(0, new ListItem("-- jenis tagihan --", string.Empty));

                //populate dropdownlist aksi debitur
                //txtDueDateAwal.Text = base.UserID.ToString();
                DataTable dtDebtor = new DataTable();
                dtDebtor = rptRecBillingDal.getDataAksiDebitur(base.UserID);
                dtDebtor.Columns.Add("FullName",typeof(string), "DebtorSectorID + '-' + DebtorName + '-' + SectorName + '-' + SubSectorName + '-' + SubSubSectorName");

                if (dtDebtor.Columns.Count > 0)
                {
                    ddlAksiDebitur.DataSource = dtDebtor;
                    ddlAksiDebitur.DataTextField = "FullName";
                    ddlAksiDebitur.DataValueField = "DebtorSectorID";
                    ddlAksiDebitur.DataBind();
                }

                ddlAksiDebitur.Items.Insert(0, new ListItem("-- aksi debitur --", string.Empty));
            }
        }
    }
}